package view.frame;

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;

import adapter.ActionAdapter;

import view.panel.CustomerPanel;
import view.panel.MenuPanel;
import view.panel.OrderPanel;

public class MyFrame extends JFrame{
	
	private Container currentPane;
	
	public MyFrame() {
	
		
		setSize(800, 500);		
		setVisible(true);		
		
		JMenuBar menuBar = new JMenuBar();
				
		JMenu orderMenu = new JMenu("주문관리");
		JMenu menusMenu = new JMenu("메뉴관리");
		JMenu customerMenu = new JMenu("고객관리");
	
		menuBar.add(orderMenu);
		menuBar.add(menusMenu);
		menuBar.add(customerMenu);
				
		setJMenuBar(menuBar);
		
				
		orderMenu.addMouseListener(new adapter.MouseAdapter(){
			@Override
			public void mouseClicked(MouseEvent e) {
				
				currentPane = getCurrentPane();
				
				if(!(currentPane instanceof OrderPanel))				
					setContentPane(new OrderPanel());
					validate();
			}
		});
		
		customerMenu.addMouseListener(new adapter.MouseAdapter(){
			@Override
			public void mouseClicked(MouseEvent e) {
				currentPane = getCurrentPane();
				
				if(!(currentPane instanceof CustomerPanel))				
					setContentPane(new CustomerPanel());
					validate();
			}
			
		});
		
		menusMenu.addMouseListener(new adapter.MouseAdapter(){
			@Override
			public void mouseClicked(MouseEvent e) {
				currentPane = getCurrentPane();
				
				if(!(currentPane instanceof MenuPanel))				
					setContentPane(new MenuPanel());
					validate();
			}
			
		});
	
	
	}
	
	private Container getCurrentPane() {
		return this.getContentPane();
	}
		
	
}
